package com.mkyong;

import java.util.Date;

import com.dmgo.common.Depo;
import com.dmgo.common.Way;
import org.hibernate.Session;

import com.mkyong.stock.Stock;
import com.mkyong.stock.StockDetail;
import com.mkyong.util.HibernateUtil;

public class App {
	public static void main(String[] args) {
		System.out.println("Hibernate one to one (Annotation)");
		Session session = HibernateUtil.getSessionFactory().openSession();

		session.beginTransaction();
/*
		Stock stock = new Stock();
		stock.setStockCode("7052");
		stock.setStockName("PADINI");

		StockDetail stockDetail = new StockDetail();
		stockDetail.setCompName("PADINI Holding Malaysia");
		stockDetail.setCompDesc("one stop shopping");
		stockDetail.setRemark("vinci vinci");
		stockDetail.setListedDate(new Date());

		stock.setStockDetail(stockDetail);
		stockDetail.setStock(stock);

		session.save(stock);
        session.save(stockDetail);
        System.out.println("Stock "+ stock.toString());
        System.out.println("Stock detail "+ stockDetail.toString());

        session.delete(stockDetail);
        session.delete(stock);
*/
        Way way = new Way("bla bla", "bla bla");
        Depo depo = new Depo("depo name", "depo desription");

        way.setDepo(depo);
        depo.setWay(way);

        session.save(depo);
        session.save(way);

        System.out.println("depo "+depo.toString());
        System.out.println("way "+way.toString());

        session.delete(way);
        session.delete(depo);


		session.getTransaction().commit();
        session.close();


		System.out.println("Done");
	}
}
